package com.woniu.controller;

import com.woniu.entity.Food;
import com.woniu.service.FoodService;
import com.woniu.util.ResData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/food")
public class FoodController {
    @Autowired
    private FoodService foodService;

    @GetMapping("/queryAll")
    public ResData<?> queryAll(){
        return foodService.queryAll();
    }
    @PostMapping("/addOrder")
    public ResData<?> addOrder(@RequestBody List<Food> params, HttpServletRequest request){
        String token = request.getHeader("token");
        return foodService.addOrder(params,token);
    }
    @GetMapping("/payOrder")
    public ResData<?> payOrder(String orderNum){
        return foodService.payOrder(orderNum);
    }
}
